package com.credithc.customers.manager.controller;

import com.credithc.baseserv.core.codes.CoreCodes;
import com.credithc.baseserv.core.message.Message;
import com.credithc.baseserv.core.message.MessageFactory;
import com.credithc.baseserv.pageHelper.PageInfo;
import com.credithc.customers.manager.ro.CustomerAccountInfoRo;
import com.credithc.customers.manager.service.CustomerAccountService;
import com.credithc.customers.manager.vo.AccountCountVo;
import com.credithc.customers.manager.vo.CustomerAccountVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Title: 客户账户相关业务
 * @Author: zhq
 * @Date: 2018/12/17
 * @Description: com.credithc.customers.manager.controller
 * @Version: V1.0.0
 */
@RestController
@RequestMapping("/manager/yzt/v1/customer/account")
public class CustomerAccountController {
    @Autowired
    CustomerAccountService customerAccountService;

    @Autowired
    MessageFactory messageFactory;
    @GetMapping("/search")
    public Message search(CustomerAccountInfoRo ro, @RequestParam(name = "pageNo",defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize",defaultValue = "20") Integer pageSize) {
        PageInfo<CustomerAccountVo> list = customerAccountService.getList(ro, pageNo, pageSize);
        Map<String, Object> pageInfo = new HashMap<>();
        pageInfo.put("pageInfo", list);
        return messageFactory.getInstance(CoreCodes.CORE_SUCCESS, pageInfo);
    }
    @GetMapping("/count")
    public Message getCount(String customerNo){
        List<AccountCountVo> countVos = customerAccountService.getAccountCount(customerNo);
        return messageFactory.getInstance(CoreCodes.CORE_SUCCESS, countVos);
    }
}
